﻿using Autofac;
using GC_FFW.Common.Abstractions.Interfaces.Helpers;
using GC_FFW.Common.Helpers;

namespace GC_FFW.Common.Modules.Autofac
{
	public class CommonModule : Module
	{
		#region Variables

		private readonly string _configFilePath;

		#endregion

		#region Constructors

		public CommonModule(string configFilePath)
		{
			_configFilePath = configFilePath;
		}

		#endregion

		#region Override Methods

		protected override void Load(ContainerBuilder builder)
		{
			base.Load(builder);

			builder.RegisterType<ApplicationConfiguration>().As<IApplicationConfiguration>()
				.WithParameter(
					(p, c) => p.ParameterType == typeof(string),
					(p, c) => _configFilePath)
				.SingleInstance();

			builder.RegisterType<XmlSerializerService>().As<IXmlSerializerService>().SingleInstance();

			builder.RegisterType<BrowserDialog>().As<IBrowserDialog>().SingleInstance();
		}

		#endregion
	}
}
